﻿@model ScrumTracker.Models.Task
@{
    ViewBag.Title = "Task #" + Model.IssueId;
    Layout = "~/Views/Shared/_Layout5.cshtml";
}
@if (false)
{
    <script src="../../Scripts/jquery-1.5.1-vsdoc.js" type="text/javascript"></script>
}
@section head{
    <script type="text/javascript">
        $(function () {
            $('#newComment').submit(function (e) {
                e.preventDefault();
                var arr = $(this).serializeArray();
                var reqData = {};
                $(arr).each(function (i, prop) {
                    reqData[prop.name] = prop.value;
                });
                if (!reqData["CommentText"] || reqData["CommentText"] == "") {
                    alert('plase enter message');
                    return false;
                }

                $.ajax({
                    url: '@(Url.Action("create", "comments"))',
                    type: 'POST',
                    dataType: 'json',
                    data: JSON.stringify(reqData),
                    contentType: 'application/json; charset=utf-8',
                    success: function (data) {
                        if (!data || data.success == false) {
                            alert('error adding comment');
                        }
                        else {
                            $('#commentsCont').html(data.html);
                        }
                    }
                });
            });
        });
    </script>
}
<div class="ui-tabs ui-widget ui-widget-content ui-corner-all" style="overflow: hidden;">
    <ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
        <li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active">
            <a href="@Url.Action("Get", "Tasks", new { @id = Model.IssueId })">Task Details</a></li>
        <li class="ui-state-default ui-corner-top">
            <a href="@Url.Action("Edit", "Tasks", new { @id = Model.IssueId })">Edit</a></li>
    </ul>
    <div class="ui-tabs-panel ui-widget-content ui-corner-bottom">
        @Html.DisplayForModel(new { AssigneeName = Model.AssigneeName })
        <div id="tabs">
            <ul>
                <li>
                    <a href="#comments">Comments</a></li>
                <li>
                    <a href="#attachments">Attachments</a></li>
            </ul>
            <div id="comments">
                <form id="newComment">
                    <input type="hidden" name="IssueId" value="@Model.IssueId" />
                    <div class="editor-label">
                        <label for="CommentText">Comment Text</label></div>
                    <div class="editor-field">
                        <textarea class="text-box multi-line" id="CommentText" name="CommentText"></textarea>
                    </div>
                    <input type="submit" value="Submit" class="button" />
                </form>
                <hr />
                <div id="commentsCont">
                    @{
                        var commentsGrid = new WebGrid(Model.Comments.OrderByDescending(s => s.CreatedAt), canSort: false, canPage: false);
                        @commentsGrid.GetHtml(tableStyle: "table-issues", headerStyle: "ui-widget-header")
                    }
                </div>
            </div>
            <div id="attachments">
                <p>
                    Mauris eleifend est et turpis. Duis id erat. Suspendisse potenti. Aliquam vulputate, pede vel vehicula accumsan, mi neque rutrum erat, eu congue orci lorem eget lorem. Vestibulum non ante. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Fusce sodales. Quisque eu urna vel enim commodo pellentesque. Praesent eu risus hendrerit ligula tempus pretium. Curabitur lorem enim, pretium nec, feugiat nec, luctus a, lacus.</p>
                <p>
                    Duis cursus. Maecenas ligula eros, blandit nec, pharetra at, semper at, magna. Nullam ac lacus. Nulla facilisi. Praesent viverra justo vitae neque. Praesent blandit adipiscing velit. Suspendisse potenti. Donec mattis, pede vel pharetra blandit, magna ligula faucibus eros, id euismod lacus dolor eget odio. Nam scelerisque. Donec non libero sed nulla mattis commodo. Ut sagittis. Donec nisi lectus, feugiat porttitor, tempor ac, tempor vitae, pede. Aenean vehicula velit eu tellus interdum rutrum. Maecenas commodo. Pellentesque nec elit. Fusce in lacus. Vivamus a libero vitae lectus hendrerit hendrerit.</p>
            </div>
        </div>
    </div>
</div>
